(function(app){
	app
		.factory('myFactory',['$state','$http','$ionicHistory','$ionicLoading','$timeout',function($state,$http,$ionicHistory,$ionicLoading,$timeout){
			var factory = {};
			//日期选择
			factory.getDate = function(id,title){
				$("#"+id).datetimePicker({
			        title: title,//请选择出生年月
			        yearSplit: '-',
			        monthSplit: '-',
			        dateSplit: '',
			        times: function () {
			          return [  // 自定义的时间
			          ];
			        },
			        onChange: function (picker, values, displayValues) {
			          console.log(values);
			        }
			    });
			}

			/*factory.getDateUtil_del = function(id,title,defaultVal){
				$("#"+id).datetimePicker({
			        title: title,//请选择出生年月
			        value: defaultVal+' ',
			        yearSplit: '-',
			        monthSplit: '-',
			        dateSplit: '',
			        times: function () {
			          return [  // 自定义的时间
			          ];
			        },
			        onChange: function (picker, values, displayValues) {
			          console.log(values);
			        }
			    });
			}*/

			//日期选择-新增控件，20170623
			factory.initDateUtil = function(id,defultDate){
		   //      var currYear = (new Date()).getFullYear();// 获取年
		   //      var currMonth = (new Date()).getMonth(); // 获取月
		   //      var currDay = (new Date()).getDate(); // 获取日
		   //      var opt = {};
		   //      opt.date = {
		   //          preset : 'date'
		   //      };
		   //      opt.dft = {
		   //          theme : 'android-ics light', // 皮肤样式
		   //          display : 'modal',      // 显示方式
		   //          dateOrder: 'yymmdd',      //日期格式
		   //          dateFormat: 'yyyy-mm-dd',      //面板中日期排列格
		   //          display : 'bottom', // 日期选择模式
		   //          lang : 'zh',
		   //          //startYear : currYear-10, // 开始年份
					// startYear : currYear-120, // 开始年份
		   //          //startMonth : currMonth,
		   //          //startDate : currDay ,
		   //          //maxDate: new Date(),
		   //          showNow:true,
		   //          nowText: "今天",
		   //          yearText: '年',
		   //          monthText: '月',
		   //          dayText: '日', 
		   //          //endYear : currYear,        // 结束年份
		   //          //endMonth : currMonth,      //结束月份
		   //          //endDate : currDay           //结束日期
					// //startYear:currYear - 120, //开始年份
					// endYear:currYear + 100 //结束年份
		   //      };
				var currYear = (new Date()).getFullYear();// 获取年
				var opt={};
				opt.date = {preset : 'date'};
				opt.dft = {
					theme: 'android-ics light', //皮肤样式
					display: 'modal', //显示方式 
					display : 'bottom', // 日期选择模式
					mode: 'scroller', //日期选择模式
					dateFormat: 'yyyy-mm-dd',
					lang: 'zh',
					showNow: true,
					nowText: "今天",
					startYear: currYear - 120, //开始年份
					endYear: currYear + 100 //结束年份
				};  
		        var optDate = $.extend(opt['date'], opt['dft']);
		        //$("#"+id).mobiscroll(optDate);
            	//$("#"+id).scroller('setDate', new Date('2015-6-4'), true);
				 if(defultDate==''){
				 	//$("#"+id).mobiscroll(optDate).date(optDate);
				 	//$("#"+id).scroller('setDate', new Date(TimeNum[0], TimeNum[1]-1, TimeNum[2]), true);
					 $("#"+id).mobiscroll(optDate);
				 }else{
				 	//var TimeNum = defultDate.split('-');
				 	//$("#"+id).mobiscroll(optDate).date(optDate);
				 	//$("#"+id).scroller('setDate', new Date(TimeNum[0], TimeNum[1]-1, TimeNum[2]), true);
					 $("#"+id).mobiscroll(optDate);
					 $("#"+id).scroller('setDate', new Date(defultDate), true);
				 }
			}
			
			//日期设置-保证再次打开日期控件保持当前input中的日期，而不是原来的控件只能显示当前日期
			factory.setDateUtil = function(id,setDate){
				//$("#birthInput").scroller('setDate', new Date('2017-09-08'), true);
				$("#"+id).scroller('setDate', new Date(setDate), true); 
			}

			factory.modalSelf = function(operate,fun){
				var win_width = "";
				var win_height = "";
				var win_left = "";
				var win_top = "";
				var modal_width = "";
				var modal_height = "";
				var obj = document.getElementById("overmodal");
				var coverObj = document.getElementById("overwindow");
				var closeObj = document.getElementById("closeX");
				if (typeof window.innerWidth != 'undefined') {
					win_width = window.innerWidth;
					win_height = window.innerHeight;
				} else {
					win_width = document.documentElement.clientWidth;
					win_height = document.documentElement.clientHeight;
				}
				if (operate == 'open') {
					document.body.style.overflow = "hidden";
					obj.style.display = "block";
					coverObj.style.display = "block";
				}else if(operate == 'close'){
					document.body.style.overflow = "visible";
					obj.style.display = "none";
					coverObj.style.display = "none";
					return;
				};

				modal_width = obj.offsetWidth;
				modal_height = obj.offsetHeight;
				win_left = ((win_width-modal_width)/2).toFixed();
				win_top = ((win_height-modal_height)/2).toFixed();
				obj.style.left = win_left+"px";
				obj.style.top = win_top+"px";


				if (obj.style.display == "block") {
					if (typeof fun === "function") {
						fun();
					};
				};

				//关闭弹窗
				if (closeObj) {
					closeObj.onclick = function(){
						document.body.style.overflow = "visible";
						obj.style.display = "none";
						coverObj.style.display = "none";
					}
				};
			}

			//获取当前浏览器平台，核心考虑三种，安卓，苹果，PC浏览器
			factory.getBrowserType = function(){
				if(navigator.userAgent.indexOf('SINO_ANDROID_APP') != -1){
					return 'Android';
				}else if(localStorage.sino_app_version == 'IPAD' || navigator.userAgent.indexOf('SINO_IOS_APP') != -1){
					return 'IOS';
				}else{
					return 'Browser';
				}
			}

			//重新受理
			factory.renew = function(){
				/*$.confirm("是否重新受理该保单？", "", function() {
				 alert('确认');
				 }, function() {
				 alert('取消');
				 });*/
				$.confirm("是否重新受理？", "", function() {
					//$state.go('search');//暂时跳转到查询页面 rqyang20170605
					//$ionicHistory.clearHistory();

					/*$state.go('search',{
						index:'yes'
					});*/
					$.showLoading('正在处理,请稍候');//显示加载圈
					$timeout(function(){$.hideLoading();},2000);
					$ionicHistory.clearCache().then(function(){ 
						$state.go('search',{
							index:'yes'
						})
					})
				});
			}

			//退出移动保全
			/*factory.exit = function(){
				$.confirm("是否退出移动保全？", "", function() {
					$http({
						method: 'GET',
						url: app.domain + 'user/userOut.action'
					}).then(function successCallback(response) {
						window.location.href = '../index.html';
					}, function errorCallback(response) {
						$.alert({
							title: '',
							text: '退出系统发生异常',
							onOK: function () {}
						});
					});
				});
			}*/
			factory.exit = function(){
				$.confirm("是否退出当前受理？", "", function() {
					$http({
						method: 'GET',
						url: app.domain + 'user/userOut.action'
					}).then(function successCallback(response) {
						var sessionTimeOutFlag = response.data.data.sessionTimeOutFlag;
						var data = {
							//sessionTimeOut : sessionTimeOutFlag //"Yes" Session超时 "No":系统正常的返回
							sessionTimeOut : sessionTimeOutFlag, //"Yes" Session超时 "No":系统正常的返回
							exitSysPage : "1" //"1" 信易通首页  "2":“我”页面
						};
						setTimeout(function() {
							cordova.sino.entryLocalSys(function(){}, data);
							//cordova.sino.entryLocalSysFromOtherSys(function(){}, data);
						}, 350);
					}, function errorCallback(response) {
						$.alert({
							title: '',
							text: '退出系统发生异常',
							onOK: function () {}
						});
					});
				});
			}
			//调整太大，只能多写一个方法支持返回保全照会待办页面
			factory.exitToMpnd = function(){
				$.confirm("是否退出当前受理？", "", function() {
					$http({
						method: 'GET',
						url: app.domain + 'user/userOut.action'
					}).then(function successCallback(response) {
						var sessionTimeOutFlag = response.data.data.sessionTimeOutFlag;
						var data = {
								//sessionTimeOut : sessionTimeOutFlag //"Yes" Session超时 "No":系统正常的返回
								sessionTimeOut : sessionTimeOutFlag, //"Yes" Session超时 "No":系统正常的返回
								exitSysPage : "2" //"1" 信易通首页  "2":“我”页面
						};
						setTimeout(function() {
							cordova.sino.entryLocalSys(function(){}, data);
							//cordova.sino.entryLocalSysFromOtherSys(function(){}, data);
						}, 350);
					}, function errorCallback(response) {
						$.alert({
							title: '',
							text: '退出系统发生异常',
							onOK: function () {}
						});
					});
				});
			}
			//返回上一页
			factory.goBack = function(){
				$ionicHistory.goBack();
			}

			//弹出提示信息
			factory.alert = function(title,text,infoType){
				$.alert({
					title: title,
					text: text,
					onOK: function () {}
				});
			}

			//打开处理中loading弹幕
			factory.loadingShow = function(){
				//方式一
				/*$ionicLoading.show({
					content: 'Loading',
					animation: 'fade-in',
					showBackdrop: true,
					maxWidth: 200,
					showDelay: 0
				});*/
				//方式二
				$.showLoading('正在处理,请稍候');
			}
			//关闭处理中loading弹幕
			factory.loadingHide = function(){
				//方式一
				//$ionicLoading.hide();
				//方式二
				$.hideLoading();
				/*setTimeout(function() {
					$.hideLoading();
				}, 3000);*/
			}
			
			//转换日期方法  例如：20170225--->2017-02-25
			factory.DateTools = function(date){
				date = String(date) ;
				if($.trim(date)!=""){
					return date.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3");
				}else{
					return date;
				}
			}
			
			factory.getTimetamp = function(){
				var timestamp = (new Date()).valueOf(); 
				return timestamp;
			}
			
			factory.hex = function(s){
				var k=generate();
				//console.log("k:"+k);
				return hex_md5(s+k);
			}
			
			function generate(){
				var hex="\u0031\u0038\u0065\u0064\u0064\u0065\u0033\u0038\u002d\u0062\u0065\u0031\u0033\u002d\u0032\u0030\u0035\u0062\u002d\u0039\u0034\u0035\u0037\u002d\u0038\u0033\u0034\u0031\u0030\u0035\u0037\u0035\u0033\u0065\u0061\u0030";
				return ascii2native(hex);
			}
			
			function ascii2native(asciicode) {
				asciicode = asciicode.split("\\u");
				var nativeValue = asciicode[0];
				for (var i = 1; i < asciicode.length; i++) {
					var code = asciicode[i];
					nativeValue += String.fromCharCode(parseInt("0x" + code.substring(0, 4)));
					if (code.length > 4) {
						nativeValue += code.substring(4, code.length);
					}
				}
				return nativeValue;
			}
			
			factory.bankNameMatching = function(bankNameOCR){
				var simple_bank_a = ["广东发展", "广发", "建设", "工商", "民生", "兴业", "浦发", "邮政", "农业", "交通"];
				var bankName="";
				for (var i = 0; i < simple_bank_a.length; i++) {
					if (bankNameOCR.indexOf(simple_bank_a[i]) !=-1) {
						if(simple_bank_a[i]=='广东发展' || simple_bank_a[i]=='广发'){//银行名称不统一，特殊银行处理，无法模糊查询
							bankName="广东发展";
						}else{
							bankName=simple_bank_a[i];
						}
						console.log("bankName:"+bankName);//获取简称
						break;
					}
				}
				return bankName;
			}
			/*add S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）--增加功能开关  by csf 20181211 start */
            //银行签约
			//S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
			//S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231127 start
            factory.goContract = function (accountNo, accountName, accountType, bankCode, phoneNum, code, signMode, isReal,branch,signMoney,idType, id, 
            		vailddate, cvv2, sigleLimitAmount, dayLimitAmount, monthLimitAmount, dueDate, successCall, errorCall, 
            		/*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
            		/*chdrnum, itemId, insPremPyfPrdNum, pyfCodt, signTotalMoney) {*/
            		/*去除农行签约编号 add by huanghaokun 20210524 start*/
            		chdrnum, itemId, insPremPyfPrdNum, pyfCodt, signTotalMoney, /*contractNo,*/ effectDate, period, signBusType, areaCode,nationality) {
		 			/*去除农行签约编号 add by huanghaokun 20210524 end*/
		 			/*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
		 	    //S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231127 end
            	var token = sessionStorage.getItem("token");
                var timestamp = factory.getTimetamp();
                var sfis = "accountNo-accountName-accountType-bankCode-phoneNum-code-signMode-isReal-branch-signMoney-idType-id-" 
                		+ "vailddate-cvv2-sigleLimitAmount-dayLimitAmount-monthLimitAmount-dueDate-" 
                		/*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
                		//+ "chdrnum-itemId-insPremPyfPrdNum-pyfCodt-signTotalMoney-token-timestamp";
                		/*去除农行签约编号 add by huanghaokun 20210524 start*/
                		+ "chdrnum-itemId-insPremPyfPrdNum-pyfCodt-signTotalMoney-effectDate-period-signBusType-areaCode-token-timestamp";
                		/*去除农行签约编号 add by huanghaokun 20210524 end*/
                		/*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
                var signStr = "accountNo=" + accountNo + "&accountName=" + encodeURI(accountName) + "&accountType=" + accountType + "&bankCode=" + bankCode 
                + "&phoneNum=" + phoneNum + "&code=" + code + "&signMode=" + signMode +"&isReal="+isReal+"&branch="+branch
                + "&signMoney="+signMoney+ "&idType=" + idType + "&id=" + id + "&vailddate=" + vailddate + "&cvv2=" + cvv2  
                + "&sigleLimitAmount="+sigleLimitAmount+"&dayLimitAmount="+dayLimitAmount+"&monthLimitAmount="+monthLimitAmount+"&dueDate="+dueDate
                + "&chdrnum=" + chdrnum + "&itemId=" + itemId + "&insPremPyfPrdNum=" + insPremPyfPrdNum + "&pyfCodt=" + pyfCodt + "&signTotalMoney=" + signTotalMoney
                /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
                /*去除农行签约编号 add by huanghaokun 20210524 start*/
                +"&effectDate="+effectDate+"&period="+period+"&signBusType="+signBusType+"&areaCode="+areaCode
                /*去除农行签约编号 add by huanghaokun 20210524 end*/
                /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
                + "&token=" + token + "&timestamp=" + timestamp;
                
                //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
                var sign = factory.hex(signStr);
                $http({
                    method: 'GET',
                    url: app.domain + 'contract/contract.action',
                    params: {
                        accountNo: accountNo,
                        accountName: accountName,
                        accountType: accountType,//默认为银行卡
                        bankCode: bankCode,
                        phoneNum: phoneNum,//policyData.mobilephone
                        code: code,//验证码
                        signMode: signMode,
                        isReal:isReal,
                        branch:branch,
                        signMoney:signMoney,
                        idType: idType,
                        id: id,//证件号码
                        vailddate: vailddate,
                        cvv2: cvv2,
                        sigleLimitAmount:sigleLimitAmount,
                        dayLimitAmount:dayLimitAmount,
                        monthLimitAmount:monthLimitAmount,
                        dueDate:dueDate,
                       //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
                        chdrnum : chdrnum, 
                        itemId : itemId,
                        insPremPyfPrdNum : insPremPyfPrdNum,
                        pyfCodt : pyfCodt,
                        signTotalMoney : signTotalMoney,
                        //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
                        /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 start*/
                        /*去除农行签约编号 add by huanghaokun 20210524 start*/
                        //contractNo : contractNo,
                        /*去除农行签约编号 add by huanghaokun 20210524 end*/
                        effectDate : effectDate,
                        period:period,
                        signBusType: signBusType,
                        areaCode: areaCode,
                        /*S2021020516689-银行签约授权功能需求 add by huanghaokun 202010310 end*/
                        //S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231127 start
                        nationality:nationality,
                        //S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231127 end
                        'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp
                    }
                }).then(successCall, errorCall);
            }
            /*add S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）--增加功能开关  by csf 20181211 start */
			/*add S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）--增加功能开关  by jiyongchang 20181211 start */
            
          //签约开关
            factory.goBankContract = function (bankSuccess, bankError) {
                var token = sessionStorage.getItem("token");
                var timestamp = factory.getTimetamp();
                var sfis = "token-timestamp";
                var signStr = "token=" + token + "&timestamp=" + timestamp;
                var sign = factory.hex(signStr);
                $http({
                    method: 'GET',
                    url: app.domain + 'contract/bankContract.action',
                    params: { 
                        'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp
                    }
                }).then(bankSuccess, bankError);
            }
            /*add S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能）--增加功能开关  by jiyongchang 20181211 end */
			//S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） 增加银行限额判断，add by csf 2019-2-12 start
            factory.banklimit = function (success, error) {
                var token = sessionStorage.getItem("token");
                var timestamp = factory.getTimetamp();
                var sfis = "token-timestamp";
                var signStr = "token=" + token + "&timestamp=" + timestamp;
                var sign = factory.hex(signStr);
                $http({
                    method: 'GET',
                    url: app.domain + 'contract/getbanklimit.action',
                    params: { 
                        'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp
                    }
                }).then(success, error);
            }
            //S2018062604412网联政策630实施相关系统功能改造需求（移动保全2.0增加签约功能） 增加银行限额判断，add by csf 2019-2-12 end
            /*S2019012807164信易通OCR识别功能————留影签名页面 银行卡选择扫描或拍照方式调整  jiyongchang 20190513 start*/
            factory.goBankPhotoFlag = function (bankPhotoSuccess, bankPhotoError) {
                var token = sessionStorage.getItem("token");
                var timestamp = factory.getTimetamp();
                var sfis = "token-timestamp";
                var signStr = "token=" + token + "&timestamp=" + timestamp;
                var sign = factory.hex(signStr);
                $http({
                    method: 'GET',
                    url: app.domain + 'ocr/bankPhotoContract.action',
                    params: { 
                        'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp
                    }
                }).then(bankPhotoSuccess, bankPhotoError);
            }
            /*S2019012807164信易通OCR识别功能————留影签名页面 银行卡选择扫描或拍照方式调整  jiyongchang 20190513 end*/
            
            //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 start
            factory.comparePayDate = function(paymentDeadline, pyfCodt) {
            	var flag = false;
            	var dateFormat =/^(\d{4})(\d{2})(\d{2})$/;
            	if (dateFormat.test(paymentDeadline) && dateFormat.test(pyfCodt)) {
            		var time = new Date(paymentDeadline.substr(0,4) + "/" + paymentDeadline.substr(4,2) + "/" + paymentDeadline.substr(6,2)).valueOf();
            		var myDate = new Date(pyfCodt.substr(0,4) + "/" + pyfCodt.substr(4,2) + "/" + pyfCodt.substr(6,2)).valueOf();
            		if(time > myDate) {
            			flag = true;
            		}
            	}
            	console.log("P086返回缴费截止日:" + paymentDeadline + ",历史签约缴费截止日:" + pyfCodt + ",比较结果:" + flag);
            	return flag;
            }
            
            factory.getMaxInsPremPyfPrdNum = function (insPremPyfPrdNum, signInsPremPyfPrdNum) {
            	var maxInsPremPyfPrdNum = insPremPyfPrdNum;
            	if (parseInt(signInsPremPyfPrdNum) > parseInt(insPremPyfPrdNum)) {
            		maxInsPremPyfPrdNum = signInsPremPyfPrdNum;
            	}
            	console.log("P086返回缴费次数:" + insPremPyfPrdNum + ",历史签约次数:" + signInsPremPyfPrdNum + ",最大签约次数:" + maxInsPremPyfPrdNum);
            	return maxInsPremPyfPrdNum;
            }
            
            factory.getMaxMoney = function (premium, nextAmount, perAmtUpLmVal) {
            	var maxMoney = premium;
            	if (parseFloat(nextAmount) > parseFloat(premium)) {
            		maxMoney = nextAmount;
            	} 
            	
            	if (parseFloat(perAmtUpLmVal) > parseFloat(maxMoney)) {
            		maxMoney = perAmtUpLmVal;
            	}
            	
            	console.log("本次变更保费:" + premium + ",续期保费:" + nextAmount + ",P086返回单笔金额:" + perAmtUpLmVal + ",最大金额:" + maxMoney);
            	return maxMoney;
            }
            
            //授权金额按本次变更需缴付的保费与续期保费较大者（趸缴保单的续期保费按0元计算),乘以1.2倍，再向上取整。
            //保费取值*1.2 < 10000，以千元为整数单位向上取整。如计算结果为千元整数倍，则取该计算结果。
            //保费取值*1.2 >=10000，以万元为单位向上取整。如计算结果为万元整数倍，则取该计算结果。
            factory.getSignMoney = function (maxMoney) {
            	var signMoney;
            	var integerMoney = parseInt(1.2 * maxMoney);
            	console.log("取整授权金额:" + integerMoney);
            	if (integerMoney < 10000) {
            		signMoney = (parseInt(integerMoney/1000) + 1) * 1000;
            	} else {
            		signMoney = (parseInt(integerMoney/10000) + 1) * 10000;
            	}
            	console.log("取整前授权金额:"+ maxMoney + ",取整后授权金额:" + signMoney);
            	return signMoney;
            }
            
            //缴别代码系   00、趸缴；01、年缴；02、半年缴；04、季缴；12、月缴
            factory.getInsPremPyfPrdNum = function (insPremPyfPrdNum, oldBillfreq, newBillfreq) {
            	var freqType = {
            			"00" : "1",
            			"01" : "1",
            			"02" : "2",
            			"04" : "4",
            			"12" : "12"
            	};
            	//新缴费期数=（期数%旧缴别）*新缴别） 对于月缴需要加3个月
            	var newInsPremPyfPrdNum = insPremPyfPrdNum;
            	if (oldBillfreq != newBillfreq) {
            		newInsPremPyfPrdNum = (parseInt(insPremPyfPrdNum) / parseInt(freqType[oldBillfreq])) * parseInt(freqType[newBillfreq]);
            	} 
            	console.log("计算缴费期数,原有缴费期数:"+ insPremPyfPrdNum + ",旧缴费方式:" + oldBillfreq + ",新缴费方式:" + newBillfreq + ",新缴费期数:" + newInsPremPyfPrdNum);
            	return newInsPremPyfPrdNum;
            }
            
            //获取缴费截止日，月缴需+3个月
            factory.getPaymentDeadline = function (paymentDeadline, billfreq) {
            	var newPaymentDeadline = paymentDeadline;
            	if ('12' == billfreq) {
            		var dateFormat =/^(\d{4})(\d{2})(\d{2})$/;
            		if (dateFormat.test(paymentDeadline)) {
            			var date = new Date(paymentDeadline.substr(0,4) + "/" + paymentDeadline.substr(4,2) + "/" + paymentDeadline.substr(6,2));
                 	    var oldDate = date.getDate();//获取该月有多少日
                 	    date.setDate(1);//设置为1日（day）
                 	    date.setMonth(date.getMonth() + 3);//设置当前月份(从0开始)
                 	    var newDay= new Date(date.getYear(), date.getMonth()+1, 0).getDate();//获取该月有多少日
                 	    date.setDate(Math.min(oldDate, newDay));
                 	    var year = date.getFullYear();
                 	    var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
                	    var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
                	    newPaymentDeadline = year + "" + month + "" + day;
            		}
            	}
            	console.log("获取缴费截止日,原缴费截止日:"+ paymentDeadline + ",缴费方式:" + billfreq + ",新缴费截止日:" + newPaymentDeadline);
            	return newPaymentDeadline;
            }
          //S2019112910966建设银行签约授权功能需求 add by yangyan 20200223 end
			return factory;
		}])
})(app)
